package cn.com.oceansoft.osc.ms.service.impl;

import cn.com.oceansoft.osc.ms.config.AppConstant;
import cn.com.oceansoft.osc.ms.domain.Member;
import cn.com.oceansoft.osc.ms.persistence.IMemberMapper;
import cn.com.oceansoft.osc.ms.service.IMemberService;
import cn.com.oceansoft.osc.ms.utils.DesUtils;
import cn.com.oceansoft.osc.ms.utils.MD5;
import cn.ucox.web.framework.view.ApiResult;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.swing.*;

/**
 * @author wuzy
 * @created 2017-08-08-08:41
 * @email wzy@oceansoft.com.cn
 */
@Service
public class MemberServiceImpl implements IMemberService {

    @Resource
    IMemberMapper memberMapper;

    @Override
    public ApiResult getUserInfo(String id, String sign) {
        String temp=id+ AppConstant.SIGN_PERFIX;
        String md5= MD5.stringToMD5(temp);
        if(!md5.equals(sign))
        {
            return new ApiResult().failure(AppConstant.SIGN_ERROR);
        }
        String idNum = DesUtils.encrypt(id);
        Member mb = memberMapper.getUserInfoById(idNum);
        if(mb==null)
            return  new ApiResult().failure(AppConstant.DATA_NOTFOUND);

        return new ApiResult().success(mb);

    }
}
